#ifndef FACTORY_TEST_H_
#define FACTORY_TEST_H_

#include <AutoLock.hh>
#include <Factory.hh>
#include <Mutex.hh>
#include <Task.hh>
#include "Test.hh"

//
/**
 * \file FactoryTest.hh
 * \author  jsk <jsk.jinsubkim@gmail.com>
 * \version 1.0
 *
 * \class FactoryTest FactoryTest.hh
 *
 * 
 */
class FactoryTest : protected Test
{
public:
	/**
	 * \name testBaseCase
	 * 
	 * 
	 * 
	 * \return 
	 * 
	 * 성공할 경우 RETURN_OK, 
	 * 실패할 경우 RETURN_OK가 아닌 값.
	 */
	virtual ResultOf testBaseCase(Factory* Target);
	
// constant
private:
	static const Number LoopCount = 50000;
};

//
/**
 * \file FactoryTest.hh
 * \author  jsk <jsk.jinsubkim@gmail.com>
 * \version 1.0
 *
 * \class CAddTask FactoryTest.hh
 *
 * 
 */
class CountTask : public Task
{
public:
	ResultOf perform()
	{
		{
			AutoLock AutoKey(&Key);
			++Count;
		}
		
		usleep(1000);
		return RETURN_OK;
	}

	ResultOf setData(void* Data)
	{
		OwnData = (USNumber)Data;
		return RETURN_OK;
	}
	
	static Number report()
	{
		return Count;
	}
	
protected:
	Number OwnData;
	static Mutex Key;
	static Number Count;
};

#endif //FACTORY_TEST_H_